import axios from '@/utils/request';

/**
 * 新增付款单
 */
export async function AddPayment(params) {
    const res = await axios.post('/Payment/AddPayment',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 更新付款单
 */
export async function UpdatePayment(params) {
    const res = await axios.post('/Payment/UpdatePayment',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据付款单id获取付款单信息
 */
export async function QueryPaymentById(id) {
    const res = await axios.get('/Payment/QueryPaymentById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取付款单查询分页列表
 */
 export async function QueryPaymentByCondition(params) {
    const res = await axios.post('/Payment/QueryPaymentByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  *  付款单(过账)
  */
 export async function AuitPayment(params) {
    const res = await axios.post('/Payment/AuitPayment',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  *  付款单(反过账)
  */
 export async function AntiPayment(id) {
    const res = await axios.post('/Payment/AntiPayment?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


 /**
  *  作废付款单
  */
 export async function DeletePayment(id) {
    const res = await axios.post('/Payment/DeletePayment?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

